package bootTest.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class MyInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("preHandle");
        System.out.println(request.getRequestURL());
        HttpSession session = request.getSession();
        if (!isLogin(session)){
            return login(response);

        }
        return true;
    }

    private boolean isLogin(HttpSession session){

        return false;
    }

    private boolean login(HttpServletResponse response) throws IOException {
        response.sendRedirect("/111.html");
        return false;
    }



}
